<template>
	<view class="container">
		<view class="list-cell b-b m-t" @click="navTo('/package/notice/notice')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell m-t">
			<text class="cell-tit">个性化推荐</text>
			<switch checked color="#ff7144" @change="switchChange"/>
		</view>
		<view class="list-cell b-b" @click="navTo('/package/set/suggest')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">建议与反馈</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell" @click="navTo('/package/set/Aboutus')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">关于我们</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="log-out-btn" @click="toLogout">
			<van-button block>退出登录</van-button>
		</view>
	</view>
</template>

<script>
	import {
	    mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				
			};
		},
		methods:{
			...mapMutations(['logout']),

		navTo(url){
			if(!this.logout){
				url = '/pages/public/login';
			}
			uni.navigateTo({  
				url
			})  
		},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
					confirmColor:'#ff7144',
				    success: (e)=>{
				    	if(e.confirm){
				    		this.logout();
				    		setTimeout(()=>{
				    			wx.navigateTo({
									url:'/pages/public/login'
								})
				    		}, 200)
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '打开': '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},
          // 清楚缓存
		  cache(){
			uni.showModal({
				title:'清除缓存',
			    content: '缓存1kb,下载文件大小0k',
				confirmText: "清除",//这块是确定按钮的文字
				cancelText:"取消",//这块是取消的文字
				confirmColor:'#ff7144',
			    success: (e)=>{
			    	if(e.confirm){
						wx.getStorage({
							key:'token',
							success:(res) =>{
								console.log('123',res)
							}
						})
					}
			    }
			});
		  }
		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
	.van-button--default{
		margin-top: 40rpx;
		border-radius: 25px !important;
		border: 1px solid #cdcdcd !important;
		width: 85% !important;
		color: #494949 !important;
	}
</style>
